#!/bin/bash

# 
# create upgrade package:
#    tar cvfz [name].tar.gz [file1] [file2] ...
#

if [ $# -ne 2 ];
then
	echo The number of arguments is incorrect.
	exit 1
fi

SW_LINK=$1
SW_NAME=$2

DEST_DIR="/home/linaro"

curl $SW_LINK -o /tmp/$SW_NAME
if [ $? -eq 0 ];
then
	sudo kill -9 `pgrep '^rh530$'`
	sudo tar -xf /tmp/$SW_NAME -C $DEST_DIR
	/home/linaro/start.sh
fi

